# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=postsrsd
pkgver=1.6
pkgrel=3
pkgdesc="Postfix Sender Rewriting Scheme daemon"
url="https://github.com/roehling/postsrsd"
arch="all"
license="GPL-2.0"
depends=""
makedepends="cmake help2man"
pkgusers="postsrsd"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/roehling/postsrsd/archive/$pkgver.tar.gz
	10-fix-defaults.patch
	postsrsd.initd"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"

	mkdir build
	cd build

	cmake .. -DCMAKE_INSTALL_PREFIX=/usr/ \
		-DCMAKE_BUILD_TYPE=None \
		-DGENERATE_SRS_SECRET=OFF \
		-DCONFIG_DIR=/etc/postsrsd
	make all
}

check() {
	cd "$builddir"/build
	./postsrsd_tests
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir/" install

	install -d "$pkgdir/etc/postsrsd/"
	install -Dm0644 build/postsrsd.default "$pkgdir/etc/conf.d/postsrsd"
	install -Dm0755 "$srcdir/postsrsd.initd" "$pkgdir/etc/init.d/postsrsd"
}

sha512sums="b2df4cdec41361e15cd8c9207fb16564d607559bcb36dd73c9347b90e4f3c2414b88434ef1ffe6a18783f38c5960383516e40e4ffa28802a03539e52ca723aa1  postsrsd-1.6.tar.gz
96a1c4e04ded844b98e5b5e263af51389ad8f1424a0fcd923f8156a2f9491b67552fbe3b5ad972cf1279d7b0e022787d151b5151a27da43227176356848ec4d7  10-fix-defaults.patch
8541fbd517370cabf905b992ba4aeccc249c56b71bf0c3f5f50c13a4bbc9e191265632147d9f2cd617911049144abbf0f2c510d0fa41ba4268ccf1ede9798116  postsrsd.initd"
